package com.deepwiki.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;

/**
 * 目录树节点DTO
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DirectoryTreeNode {

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点标题
     */
    private String title;

    /**
     * 节点名称
     */
    private String name;

    /**
     * URL路径
     */
    private String url;

    /**
     * 父节点ID
     */
    private String parentId;

    /**
     * 排序顺序
     */
    private Integer order;

    /**
     * 内容路径（相对于存储根目录）
     */
    private String contentPath;

    /**
     * 是否已生成内容
     */
    private Boolean isGenerated;

    /**
     * 子节点列表
     */
    private List<DirectoryTreeNode> children;

    // Constructors
    public DirectoryTreeNode() {
    }

    public DirectoryTreeNode(String id, String title, String name) {
        this.id = id;
        this.title = title;
        this.name = name;
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public String getContentPath() {
        return contentPath;
    }

    public void setContentPath(String contentPath) {
        this.contentPath = contentPath;
    }

    public Boolean getIsGenerated() {
        return isGenerated;
    }

    public void setIsGenerated(Boolean isGenerated) {
        this.isGenerated = isGenerated;
    }

    public List<DirectoryTreeNode> getChildren() {
        return children;
    }

    public void setChildren(List<DirectoryTreeNode> children) {
        this.children = children;
    }

    public void addChild(DirectoryTreeNode child) {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        this.children.add(child);
        child.setParentId(this.id);
    }

    @Override
    public String toString() {
        return "DirectoryTreeNode{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", name='" + name + '\'' +
                ", url='" + url + '\'' +
                ", order=" + order +
                ", childrenCount=" + (children != null ? children.size() : 0) +
                '}';
    }
} 